import React from 'react';
import TYPE from '@design/constant/component-type';
// import Block from '@design/desktop/components/Designer/Block';
import { Table, TableCell, TableRow } from './component';

const schema = {
  block: {
    [TYPE.TABLE_ROW]: {
      isAtomic: false,
    },
    [TYPE.TABLE_CELL]: {
      isAtomic: false,
    },
  },
};
export default function(options = {}) {
  return {
    schema,
    renderBlock: (props, editor, next) => {
      const { injectProps } = options;
      const newProps = injectProps(props);
      const { type } = props.node;
      switch (type) {
        case TYPE.TABLE:
          return <Table {...newProps}>{props.children}</Table>;
        case TYPE.TABLE_ROW:
          return <TableRow {...newProps}>{props.children}</TableRow>;
        case TYPE.TABLE_CELL:
          return (
            <TableCell.DropTableCell {...newProps}>
              {props.children}
            </TableCell.DropTableCell>
          );
        default:
          return next();
      }
    },
    renderDecorator: (props, editor, next) => {
      const { type } = props.node;
      switch (type) {
        case TYPE.TABLE_CELL:
          return; 
          // <Block {...props}>{props.children}</Block>;
        case TYPE.TABLE_ROW:
          return;
        default:
          return next();
      }
    },
  };
}
